package com.orkasgb.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.orkasgb.entity.OrkasgbUserEntity;
import com.orkasgb.service.IOrkasgbUserService;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;

import java.io.Serializable;
import java.util.List;

import com.orkasgb.common.CommonResult;

/**
 * 用户表(TOrkasgbUser)表控制层
 *
 * @version 1.0.0
 * @since 2024-11-08 14:54:38
 */
@RestController
@RequestMapping("orkasgbUser")
public class OrkasgbUserController {
    /**
     * 服务对象
     */
    @Resource
    private IOrkasgbUserService orkasgbUserService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("getOrkasgbUser/{id}")
    public CommonResult<OrkasgbUserEntity> getOrkasgbUser(@PathVariable("id") Serializable id) {
        return CommonResult.ofSuccess(orkasgbUserService.getOrkasgbUser(id));
    }

    /**
     * 通过条件查询多条数据
     *
     * @param orkasgbUser 实体查询参数
     * @return 单条数据
     */
    @GetMapping("getOrkasgbUserList")
    public CommonResult<List<OrkasgbUserEntity>> getOrkasgbUserList(@ModelAttribute OrkasgbUserEntity orkasgbUser) {
        return CommonResult.ofSuccess(orkasgbUserService.getOrkasgbUserList(orkasgbUser));
    }

    /**
     * 通过条件查询多条数据(分页查询)
     *
     * @param orkasgbUser 查询参数
     * @return 单条数据
     */
    @GetMapping("getOrkasgbUserPageDataList")
    public CommonResult<IPage<OrkasgbUserEntity>> getOrkasgbUserPageDataList(@ModelAttribute OrkasgbUserEntity orkasgbUser) {
        return CommonResult.ofSuccess(orkasgbUserService.getOrkasgbUserPageDataList(orkasgbUser));
    }

    /**
     * 新增数据
     *
     * @param orkasgbUser 实体对象
     * @return 新增结果
     */
    @PostMapping("addOrkasgbUser")
    public CommonResult<Integer> addOrkasgbUser(@RequestBody OrkasgbUserEntity orkasgbUser) {
        return CommonResult.ofSuccess(orkasgbUserService.addOrkasgbUser(orkasgbUser));
    }

    /**
     * 修改数据
     *
     * @param orkasgbUser 实体对象
     * @return 修改结果
     */
    @PutMapping("updateOrkasgbUser")
    public CommonResult<Integer> updateOrkasgbUser(@RequestBody OrkasgbUserEntity orkasgbUser) {
        return CommonResult.ofSuccess(orkasgbUserService.updateOrkasgbUser(orkasgbUser));
    }

    /**
     * 修改或者新增数据
     *
     * @param orkasgbUserList 实体对象
     * @return 操作结果
     */
    @PostMapping("addOrUpdateOrkasgbUser")
    public CommonResult<Integer> addOrUpdateOrkasgbUser(@RequestBody List<OrkasgbUserEntity> orkasgbUserList) {
        return CommonResult.ofSuccess(orkasgbUserService.addOrUpdateOrkasgbUser(orkasgbUserList));
    }

    /**
     * 删除数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @DeleteMapping("deleteOrkasgbUserByIds")
    public CommonResult<Integer> deleteOrkasgbUserByIds(@RequestParam("idList") List<Long> idList) {
        return CommonResult.ofSuccess(orkasgbUserService.deleteOrkasgbUserByIds(idList));
    }
}

